package com.qianyu.project.web.controller.mfy;

import com.qianyu.project.service.IMaterialClassService;
import com.qianyu.project.service.IMaterialInfoService;
import com.qianyu.project.utils.Result;
import com.qianyu.project.utils.ResultTool;
import com.qianyu.project.web.controller.mfy.utils.MaterialClassBean;
import com.qianyu.project.web.controller.mfy.utils.MaterialClassUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author mfy
 * @desc
 */
@RestController
@RequestMapping("MfyMaterialClasss")
public class MfyMaterialClassController {

    @Autowired
    private IMaterialClassService materialClassService;

    @Autowired
    private IMaterialInfoService materialInfoService;

    @GetMapping("")
    public Result list(@RequestParam Map<String,String> params){
        Map<String,Object> map=new HashMap<>();
        List<MaterialClassBean> m = MaterialClassUtils.TreeRendering(materialClassService);
        map.put("data", m);
        map.put("materialClass", materialInfoService.MfyCreatedList(params));
        return ResultTool.success(map);
    }
}
